package com.ldcc.report_system.util;

import android.content.Context;
import android.os.IBinder;
import android.view.inputmethod.InputMethodManager;


/**
 * @author wwj[yeshengkele@outlook.com]
 * @description 键盘工具类
 */
public class KeyBroadUtils {


    /**
     * @param context 界面上下文
     * @description 键盘弹起或者会回收
     */
    public static void showOrHide(Context context) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    }

    /**
     * 收起键盘
     * @param context 界面上下文
     */
    public static void hideKeyboard(Context context, IBinder windowToken) {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(windowToken, 0);
    }
}
